<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>自由课程中的作业详情</title>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<script src="../../script/jquery.knob.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/timecontrol.min.css" />
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/attachmentCss.css">
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			body {
				background-color: #FFFFFF
			}
			html {
				background-color: #FFFFFF
			}
			.bases {
				height: 44px;
				width: 100%;
			}
			.student_study_freecourse_homeworkinfo_day {
				line-height: 1.2em;
				font-size: 16px;
				color: #222222;
			}
			.student_study_freecourse_homeworkinfo_time {
				color: #222222;
				font-size: 14px;
				float: right;
				padding-right: 10px
			}
			.text_fe {
				/*text-indent:2em;*/
				background: url(../../image/icon111.png) 0px top no-repeat, url(../../image/icon222.png) right bottom no-repeat;
				background-size: 16px;
				margin-top: 15px;
				/*margin:10px;*/
			}
			.bott_file {
				padding: 15px;
				width: 100%;
				height: 30px;
				line-height: 30px;
				background-color: #FFFFFF
			}
			.bott_text {
				padding: 15px;
				display: inline;
				/*padding-left: 15px;*/
			}
			.linlne {
				height: 100%;
			}
			button {
				border: 1px solid #fdaa52;
				background-color: #fdaa52;
				margin: 40px auto 40px auto;
				width: 80%;
				padding: 8px 0;
				margin-top: 30px;
				margin-bottom: 50px;
			}
			.title {
				line-height: 1.2em;
				font-size: 16px;
				color: #323232;
				padding-left: 10px;
			}
			#bewriteDIV {
				background-color: #FFFFFF;
			}
			.CellFrame {
				float: left;
				position: relative;
				padding-left: 10px;
				padding-top: 10px;
				padding-bottom: 10px;
				width: 33%;
				height: 120px
			}
			.picCell {
				width: 100%;
				height: 100%
			}
		</style>
	</head>
	<body>
		<div id="bewriteDIV" hidden="hidden">
				<div class="padding10">
					<p class=" base_black_grey base_title_font">
						描述
					</p>
					<div class="base_dark_grey base_content_font according-2-rows text_indent_2" id="bewrite" onclick="openBewrite()">
						
					</div>
				</div>
				<div class="div_divider"></div>
				<div style="background-color: #f0f0f0;height:5px"></div>
				<div class="div_divider"></div>
			</div>
		<div id="item1" class="mui-control-content mui-active  bottom_30">
			<div class="feeling clearfix">
				<p class="title"></p>
				<p class="student_study_freecourse_homeworkinfo_day">
					提交日期 <em class="student_study_freecourse_homeworkinfo_time" id="ttime"> </em>
				</p>
				<div class="text_fe" >
					<p id="content" class="bottom_10  text_indent_2  base_title_font base_dark_grey" style="word-wrap:break-word;word-break:break-all;">
						<!--暂无数据！！！！-->
					</p>
					<div id="img_show" style="text-align:center"></div>
				</div>
					<!--添加图片！！！！-->
				<div id="addPhoto">
				<!--<div class="CellFrame">
						<img class="picCell" src="../../icon/icon_picAdd.png" >
					</div>-->
					
				</div>
				<div id="stu_attachmentTableView">
		
					<!--<div class="font16"> <a class="a_style_xiazai" >下周完成巍问问周完成巍问问周完成巍问问          <span style="margin-left: 10px;margin-right: 10px;color: #333333;">(16.0M)</span><img  class="img_style_xiazai" src="../../image/doc_icon_studied.png" /></a></div>
					</div>-->
				</div>
				
				</div>
				
			<div class=" top_10 " style="background: #fff;">
				<div hidden="hidden" id="backs" style="padding-top: 10px; padding-left: 20px;">
					<p class="title "style="margin-bottom:0;" >
						反馈
					</p>
					<br />
					<p class="base_title_font  base_dark_grey">
						你提交的作业已经被老师驳回，请重新提交
					</p>
				</div>
			</div>
			<div class=" top_10 " id="pingl"  style="background: #fff;">
				<div style="padding-top: 10px; padding-left: 20px;" hidden="hidden" id="backs1">
					<p class="title "style="margin-bottom:0;">
						反馈
					</p>
				</div>
				<div class="ReviewWeekly_div  top_15 " id="backs2" hidden="hidden" >
					<div class="applyjob ">
						<form class="mui-input-group font14 base_grey">
							<div class="mui-input-row padding_left_10">
								<label  class="base_title_font  base_black_grey">成绩</label>
								<span class="stuname base_title_font  base_dark_grey" id="comment_score"></span>
							</div>
							<div class="mui-input-row padding_left_10">
								<label class="base_title_font  base_black_grey" >评分时间</label>
								<span class="stuname base_title_font  base_dark_grey" id="comment_time"></span>
							</div>
							<div class="mui-input-row padding_left_10">
								<label  class="base_title_font  base_black_grey">评分人</label>
								<span class="stuname base_title_font  base_dark_grey" id="comment_name"></span>
							</div>
						</form>
					</div>
				</div>
				<div id="item1" class="mui-control-content mui-active top_10 bottom_30">
					<div class="feeling"  id="pingyu" hidden="hidden" >
						<p class="student_study_freecourse_homeworkinfo_day base_title_font  base_black_grey"  style="padding-left: 3px;">
							评语
						</p>
						<div class="feeling-text">
							<p id="summary" class="bottom_10  text_indent_2  base_title_font base_dark_grey" style="word-wrap:break-word;word-break:break-all;"></p>
						</div>
					</div>
					<div class="feeling"  id="pizhu" hidden="hidden" >
						<p class="student_study_freecourse_homeworkinfo_day" >
							附件
						</p>
						<div id="teacher_attachmentTableView" >
							<!--<div class="font16"> <a class="a_style_xiazai" >下周完成巍问问周完成巍问问周完成巍问问          <span style="margin-left: 10px;margin-right: 10px;color: #333333;">(16.0M)</span><img  class="img_style_xiazai" src="../../image/doc_icon_studied.png" /></a></div>
							</div>-->
						</div>
					</div>
					<div hidden="hidden" id="tijiao">
						<button id="sumbit_bt" type="button" class=" top_30 bottom_30 mui-btn mui-btn-warning mui-btn-block  " onclick="Upload_data()">
							重新提交
						</button>
					</div>
					<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
						<div class="weui_mask"></div>
						<div class="weui_dialog">
							<div class="weui_dialog_hd">
								<strong class="weui_dialog_title">是否放弃在此页面操作？</strong>
							</div>
							<div class="weui_dialog_bd"></div>
							<div class="weui_dialog_ft">
								<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
								<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
							</div>
						</div>
					</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/timeStampTool.js"></script>
	<script src="../../script/processing_images.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/attachmentManager.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript">
		var data = new Object();
		var work_time = "";
		var work_descs = "";
		var work_score = "";
		var work_times = "";
		var work_score_name = "";
		var work_summary = "";
		var currentImageArr = new Array();
		DBReady = function() {
			data = api.pageParam.datas;
		
			setupBewriteShowOrHide();
			setupDownloadAttNotifi();
			loadData(data);
			api.addEventListener({
				name : 'HomeWorkBackNotifi'
			}, function(ret, err) {
				api.sendEvent({
					name : 'HomeWorkConfirmBackNotifi'
				});
			});
		};
		function setupBewriteShowOrHide() {
			var bewrite = data.json.workbewrite;
			if (bewrite != "" && bewrite != null && bewrite != undefined) {
				$('#bewriteDIV').show();
				if (removeHTMLTag(bewrite).length > 0) {
					$('#bewrite').html(removeHTMLTag(bewrite));
				} else {
					$('#bewrite').html('点击查看详情');
				}
			}
		}

		function openBewrite() {
			api.openWin({useWKWebView:true,
				name : 'Student_Free_bewrite',
				url : 'Student_Free_bewrite.html',
				pageParam : {
					cdetailtitle : data.json.workname,
					bewrite : data.json.workbewrite,
					is_dis_bewrite : data.json.is_dis_bewrite
				}
			});
		}

		function iGetInnerText(testStr) {
			var resultStr = testStr.replace(/\ +/g, "");
			//去掉空格
			resultStr = testStr.replace(/[ ]/g, "");
			//去掉空格
			resultStr = testStr.replace(/[\r\n]/g, "");
			//去掉回车换行
			return resultStr;
		}

		function loadData(data) {
			var list = data.json;
			var arr = new Array();
			var stuData = new Object();
			if (list.hasOwnProperty('file')) {
				var file = list.file;
				var reg = /[a-zA-Z]/g;
				var attArr = new Array();
				var fid = MD5(file.fileurl);
				fid = fid.replace(reg, "");
				fid = fid.substring(0, 5);
				stuData = {
					id : fid,
					url : file.fileurl,
					size : file.filesize,
					name : file.filename
				};
			}
			if (list.status == 0) {//未审核
				work_score = "尚未审核";
				$("#backs1").show();
				$("#backs2").show();
				$("#pingyu").show();
				$("#tijiao").show();
				// 如果没有审核过，可以进行二次上传，显示一个“再次上传”的按钮
			} else if (list.status == 1) {//驳回
				work_score = "已被驳回";
				$("#backs").show();
				$("#tijiao").show();
			} else {
				$("#backs1").show();
				$("#backs2").show();
				$("#pingyu").show();
				var checkfile = data.json.checkfile;
//				 alert(JSON.stringify(checkfile));
				if (checkfile == "" || checkfile == null) {
					$("#pizhu").hide();
				} else {
					$("#pizhu").show();
					var filedes = [];
					filedes = checkfile.split("||");
					var reg = /[a-zA-Z]/g;
					var attArr = new Array();
					var fid = MD5(filedes[1]);
					fid = fid.replace(reg, "");
					fid = fid.substring(0, 5);
					var furl = filedes[1];
					var fname = filedes[0];
					var fsize = list.size;
					var attObjc = {
						id : fid,
						url : furl,
						size :fsize,
						name : fname
					};
//					 alert(JSON.stringify(attObjc));
					attArr.push(attObjc);
					//					$('#attachmentTableView').html('');
					saveAttDatasToDb(attArr, '#teacher_attachmentTableView');
				}
				//学生添加附件显示
				work_score = data.json.score;
				work_times = timeStringWithTimeStamp(data.json.asstime + "000");
				work_score_name = data.json.teachername + "老师";
				if (work_score_name == null) {
					work_score_name = '--';
				}
				work_summary = data.json.comment;
				work_summary = work_summary.replace(/<\/?.+?>/g, "");
			}
			arr.push(stuData);
			saveAttDatasToDb(arr, '#stu_attachmentTableView');
			$("#ttime").text(isString(timeStringWithTimeStamp(list.endtime + "000")));
			// 作业内容
			var content = list.content;
			$("#content").text(isString(content.replace(/<\/?.+?>/g, "")));
			listImg(list.imglist);
			// 成绩
			$("#comment_score").text(isString(work_score));
			// 评分时间
			$("#comment_time").text(isString(work_times));
			// 评分人
			//	    $("#comment_name").text(work_score_name);
			$("#comment_name").text(isString(work_score_name));
			// 反馈语
			$("#summary").html(isString(work_summary));
			setupImage();
		}
		function listImg(data){
			if(data == undefined || data == null || data == '' ){
				return;
			}
			currentImageArr = data;
			var imageHtmls = '';
			//	alert(data.length);
			//	console.log(JSON.stringify(data));
			for(var i=0;i<data.length;i++){
				var imageHtml= '<div class="CellFrame">'+
							'<img class="picCell" src='+data[i]+' onClick="showTapImg('+ i +')">'+
						'</div>';
			 	imageHtmls = imageHtmls + imageHtml;
			}
			//	console.log(JSON.stringify(imageHtmls));
			$("#addPhoto").html(imageHtmls);
		}
		function showTapImg(index){
			// var imageBrowser = api.require('imageBrowser');
			// imageBrowser.openImages({
			//     imageUrls: currentImageArr,
			//     showList: false,
			//     activeIndex: index
			// });
		}
		function showAlert() {
			backClick();
		}

		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#offlineAlert').hide();
			backClick();
		}

		function setupImage() {
			var newWidth = api.winWidth - 100;
			$("img").each(function(i) {
				var oldWith = $(this).width();
				if (oldWith == 0) {
					setTimeout(function() {
						setupImage();
					}, 500);
					return;
				}
				// alert('oldWith:'+oldWith+'\nnewWidth'+newWidth);
				if (oldWith > newWidth) {
					var oldHeight = $(this).height();
					var newHeight = oldHeight * (newWidth / oldWith);
					$(this).width(newWidth);
					$(this).height(newHeight);
				}
			});
		}

		function Upload_data() {
			api.sendEvent({
				name : 'upload_again'
			});
			api.closeFrame({
				name : "new_student_study_freecourse_homeworkinfo"
			});
		}
	</script>
</html>